package com.shtel.bss.saas.core.data.common.entiry.repository;

import com.shtel.bss.saas.core.data.common.mapper.IBaseMapper;
import com.shtel.bss.saas.core.data.common.entiry.IBaseEntity;
import com.shtel.bss.saas.core.data.common.mapper.MapperFactory;

/**
 * @author xiezhiwei
 * @version Revision 1.0
 * @版权： 版权所有 (c) 2018
 * @创建日期： 2020/2/4 10:17
 * @功能说明：
 */
public interface IBaseRepository<T extends IBaseEntity> {

	default <T> IBaseMapper mapper(Class<T> clazz) {
		return MapperFactory.getMapper(clazz);
	}

	default <T> void save(T entity) {
		mapper(entity.getClass()).insert(entity);
	}

	default <T> void update(T entity) {
		mapper(entity.getClass()).updateByPrimaryKey(entity);
	}

	default <T>  void remove(T entity) {
		mapper(entity.getClass()).delete(entity);
	}

}
